package com.todo.member.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author azhebuxing
 * @date 2025/2/12 12:00
 * @description
 */
@Getter
@AllArgsConstructor
public enum MemberTaskCirculateTypeEnum {

    ONCE(1, "ONCE", "一次性任务"),
    DAY_CIRCULATE(2, "DAY_CIRCULATE", "天循环"),
    WEEK_CIRCULATE(3, "WEEK_CIRCULATE", "周循环"),
    MONTH_CIRCULATE(4, "MONTH_CIRCULATE", "月循环"),
    TIMELINESS_ONCE(5, "TIMELINESS_ONCE", "特定时效一次任务"),
    TIMELINESS_CIRCULATE(6, "TIMELINESS_CIRCULATE", "特定时效循环任务"),
    ;

    private static Map<Integer, MemberTaskCirculateTypeEnum> typeMap = Arrays
            .stream(MemberTaskCirculateTypeEnum.values())
            .collect(Collectors.toMap(MemberTaskCirculateTypeEnum::getType, item -> item, (v1, v2) -> v2));

    private int type;
    private String code;
    private String name;


    public static MemberTaskCirculateTypeEnum getByType(Integer type) {
        return typeMap.get(type);
    }
}
